import threading
import time


class Clock(threading.Thread):
    
    def __init__(self):
        threading.Thread.__init__(self)
        self.listeners = []
    
    def run(self):
        self.timing()

    def register(self, listener):
        self.listeners.append(listener)

    def notify_listeners(self):
        for listener in self.listeners:
            listener.tick()
            
    def timing(self):
        while True:
            self.notify_listeners()
            print('Clock Tick tock !')
            time.sleep(2)
            #sys.stdout.flush()          